﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using secondhand.L3object;
using secondhand.L2busslogic;
using secondhand.L1database;
namespace secondhand.L4view.yonghu
{
    public partial class yonghu_withdraw : System.Web.UI.Page
    {
        public static userOB yy = new userOB();
        protected void Page_Load(object sender, EventArgs e)
        {
            yy = userBL.Getwordsingle(Session["login"].ToString());
            Label3.Text = yy.user_name;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            userOB mydd = new userOB();
            userOB myaa = new userOB();

            mydd = userBL.Getwordsingle(Session["login"].ToString());
            myaa = userBL.Getwordsingle(Label3.Text.Trim());

            if (TextBox1.Text.Trim().Length == 0)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert(提现的金额不能为空!');</script>");
                return;
            }

            if (TextBox4.Text.Trim().Length == 0)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('输入的银行账号不能为空!');</script>");
                return;
            }
            if (TextBox2.Text.Trim().Length == 0 || TextBox2.Text != mydd.pass_word)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('密码有误!');</script>");
                return;
            }

            int num = Convert.ToInt32(TextBox1.Text);
            int num1 = Convert.ToInt32(myaa.usable_count);
            int sum;
            sum = num1 - num;
            num1 = num1 - num;
            if (sum < 0)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('可用余额小于0 ');</script>");
                return;
            }
            else
            {
                mydd.user_count = sum.ToString();
                mydd.usable_count = num1.ToString();
                if (!userBL.Savemark(mydd))
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('提现不成功 ');</script>");
                    return;
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('提现成功 ');</script>");
                    return;
                }

            }
        }


        protected void Button2_Click(object sender, EventArgs e)
        {
            userOB mycc = new userOB();

            mycc = userBL.Getwordsingle(Label3.Text.Trim());
            TextBox6.Text = mycc.user_count;
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            userOB mycc = new userOB();

            mycc = userBL.Getwordsingle(Label3.Text.Trim());
            TextBox3.Text = mycc.usable_count;
        }

        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

    }
}